#
# Setup evnt. libs. for current platform
#
message(STATUS "Setup extra depends for ${PLATFORM_TYPE}")

# T2H library definitions
if (DEFINED CORE_SHARED)
	add_definitions(-DSIGCORE_CORE_EXPORT -DSIGCORE_CORE_SHARED)
endif()

if (CMAKE_BUILD_TYPE MATCHES Debug) 
	add_definitions(-DSIGCORE_CORE_DEBUG)
else()
	add_definitions(-DNDEBUG)
endif()

set(USE_MONGOOSE_HTTP_TRANSPORT TRUE)
add_definitions(-DNO_CGI)

# Generic_config allow to setup envt. for the libraries, envt_config allow to setup paths to libraries
include(${CMAKE_SOURCE_DIR}/CMakeExtra/${PLATFORM_TYPE}/Config.cmake OPTIONAL)
include(${CMAKE_SOURCE_DIR}/CMakeExtra/${PLATFORM_TYPE}/EnvtConfig.cmake OPTIONAL)

# Find & setup the boost library
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_DATE_TIME ON)
set(Boost_USE_STATIC_RUNTIME OFF)

# Setup Boost library.
# Allow to avoid link errors inside Boost.Asio, if we link against boost dynamicly.
#add_definitions(-DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_DISABLE_EXCEPTION -DBOOST_ASIO_SEPARATE_COMPILATION)

find_package(Boost 1.45.0 COMPONENTS
	filesystem
	program_options
	thread
	system
	date_time
	iostreams
	unit_test_framework
	REQUIRED)

if (UNIX OR APPLE)
	set(Boost_LIBRARIES ${Boost_LIBRARIES} pthread)
	set(Boost_THREAD_LIBRARY ${Boost_THREAD_LIBRARY} pthread)
endif()

if (WIN32)
	set(Boost_LIBRARIES ${Boost_LIBRARIES} wsock32 ws2_32) 
endif()

include_directories(${Boost_INCLUDE_DIR})

# Setup OpenSSL
if (USE_OPEN_SSL)
	set(OPENSSL_USE_STATIC_LIBS ON)
	set(OPENSSL_USE_STATIC_RUNTIME OFF)
	find_package(OpenSSL PATHS ${CMAKE_SOURCE_DIR}/CMakeExtra REQUIRED)
	include_directories(${OPENSSL_INCLUDE_DIR})
endif()

find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
if(HOST_PROTOBUF_PROTOC)
	set(PROTOBUF_PROTOC_EXECUTABLE ${HOST_PROTOBUF_PROTOC})
endif(HOST_PROTOBUF_PROTOC)


